<?php if (!defined('THINK_PATH')) exit();?><script>
	//ajax导入电话号码
	function ajaxFileUpload(){
		$.ajaxFileUpload({
			url:'__APP__/SMS/importFile/hash/'+$("input[name='hash']").val(),
			fileElementId:'txtimport',
			dataType:'json',
			success:function(data,status){
				$.warn("提示",data.info);
				if(data.status == 1){
					$("#sendnumber").append(data.data.mobiles);
					$(".success-phone-num").html(data.data.success);
					$(".fail-phone-num").html(data.data.fail);
				}
			}
		});
	}
	//给输入号码框绑定键盘Enter时间
	keyboards_Enter("inputnumber","sendnumber");
	//加载短信库的内容
	function loadHolidayMenu(){
		$("#maincontent").attr("id","mymaincontent");
		$.dialog("短信库","__APP__/SMS/smsTemplateInsert",1);
		
		
	}
</script>
<div>
<form id="send-sms-form" onsubmit="return false;">
	<table class="table table-bordered">
		<tr>
			<td><?php echo (L("inputnumber")); ?>:</td>
			<td><input type="text" style="width:600px" id="inputnumber"><br/>
				<span><?php echo (L("inputnumber-tips")); ?></span>
			</td>
		</tr>
		<tr>
			<td><?php echo (L("sendnumber")); ?>:</td>
			<td>
				<textarea style="width:600px;margin-bottom:5px;height:100px;" value="" id="sendnumber" readonly="readonly"></textarea><br/>
				<input type="hidden" value="" name="mobiles" class="sendnumber"/>
				<a class="btn clear" onclick="$('#sendnumber').val('')"><?php echo (L("clear")); ?></a>
				<a class="btn" onclick="contactImport()"><?php echo (L("contactimport")); ?></a>
				<span style="overflow:hidden;position:relative;">
					<input type="file" style="opacity:0;filter:alpha(opacity=0);position:absolute;width:100px" id="txtimport" onchange="ajaxFileUpload();" name="upload_file"/>
					<a class="btn"><?php echo (L("txtimport")); ?></a>
				</span>
				<!--<span style="overflow:hidden;position:relative;"><input type="file" style="opacity:0;filter:alpha(opacity=0);position:absolute;width:100px"/><a class="btn"><?php echo (L("excelimport")); ?></a></span>-->
				<span><input type="checkbox"/><?php echo (L("filternumber")); ?></span><br/>
				<span id="telephonenumber" style="margin-top:5px;display: block;">最多提交50000个号码， 成功提交<i class="success-phone-num">0</i>个号码，失败<i class="fail-phone-num">0</i>个号码，导入txt文件格式为一行一个号码</span>
			</td>
		</tr>
		<tr>
			<td><?php echo (L("sendcontent")); ?>:</td>
			<td>
				<textarea style="width:600px;margin-bottom:5px;" id="sendcontent" oninput="statWordNum(id);" name="sms_content"></textarea><br/>
				<a class="btn clear" onclick="$('#sendcontent').val('')"><?php echo (L("clear")); ?></a>
				<a class="btn" id="phrase" onclick="loadHolidayMenu();"><?php echo (L("phrase")); ?></a>
				<a class="btn" id="phrase" onclick="addToTemplate()"><?php echo (L("joinphrase")); ?></a>
				<a class="btn" id="phrase" onclick="checkBlackword()"><?php echo (L("black-dictionary")); ?></a>
				<a class="btn" id="phrase" onclick="signature()"><?php echo (L("company-signed")); ?></a>
				<span><input type="checkbox"/>是否启用长短信</span><br/>
				<span id="word-number" style="margin-top:5px;display: block;">普通短信每条70个字符， 长短信每条210个字符， 已输入<i>0</i>个字符</span>
			</td>
		</tr>
		<tr>
			<td><?php echo (L("sendtime")); ?>:</td>
			<td>
				<div id="datetimepicker" class="input-append date">
				  <input type="text"></input>
				  <span class="add-on">
					<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
				  </span>
				</div>
				<span>空表示即时发送</span>
			</td>
		</tr>
		<tr>
			<td><?php echo (L("sendmethod")); ?>:</td>
			<td>
				<input type="radio" name="send_way" value="1" checked/>通道一<input type="radio" name="send_way" value="2"/>通道二<input type="radio" name="send_way" value="3"/>通道三
			</td>
		</tr>
		<tr>
			<td colspan="2">
				<input type="hidden" class="draft" value="0" name="draft"/>
				<input type="button" class="btn btn-info" value="立即发送" onclick="$('.draft').val('0');$('#send-sms-form').submit();"/>
				<input type="button" class="btn" style="margin-left:10px" value="存入草稿" onclick="$('.draft').val('1');$('#send-sms-form').submit();"/>
			</td>
		</tr>
	</table>
	<input type="hidden" value="<?php echo ($hash); ?>" name="hash"/>
</form>
</div>
<script>
	$("#datetimepicker").datetimepicker({format:"yyyy-MM-dd hh:mm:ss"});
	$.getScript("__PUBLIC__/js/jquery/jquery.form.js",function(){
		$("#send-sms-form").submit(function(){
			var $sms_mobiles = $("input[name='mobiles']").val();
			if($sms_mobiles != ''){
				$(this).ajaxSubmit({
					url:'__APP__/SMS/smsSend',
					dataType:'json',
					success:function(json){
						$.warn('提示',json.info);
					}
				});
			}else{
				$.warn('提示',"号码不能为空");
			}
		});
	});
	function signature(){
		$.getJSON("__APP__/Account/getSignature",function(json){
			if(json.status ==1){
				var $sendContent = $('#sendcontent').val();
				 $('#sendcontent').val($sendContent + "[" + json.data.signature + "]");
			}else{
				 $.warn("系统提示",json.info);
			}
		});
	}
	function checkBlackword(){
		var $sendContent = $('#sendcontent').val();
		$.getJSON("__APP__/SMS/checkBlackword",{word:$sendContent},function(json){
			if(json.status == 1){
				 $.warn("敏感词汇如下，请修改",json.data);
			}else{
				 $.warn("系统提示",json.info);
			}
		});
	}
	function contactImport(){
		$("#maincontent").attr("id","mymaincontent");
		$.dialog("选择联系人","__APP__/Contacts/selectContact");
		$(".modal-dialog .modal-body").attr("id","maincontent");

	}
	function addToTemplate(){
		var $sendContent = $('#sendcontent').val();
		$.getJSON("__APP__/SMS/smsTemplateAdd",{sms_content:$sendContent},function(json){
			$.warn("系统提示",json.info);
		});
	}
</script>